/*!
 *  @file
 *  @author Ed Lai
 *  
 *  @section LICENSE
 *  
 *  This file is part of Pic2Lcd.
 *  
 *  Copyright (C) 2010 Ed Lai
 *  
 *  Pic2Lcd is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Pic2Lcd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with Pic2Lcd.  If not, see <http://www.gnu.org/licenses/>.
 *  
 *  @section DESCRIPTION
 *  
 *  AboutDialog class implementation
 *
 */

#ifndef ContentsDialog_cpp
#define ContentsDialog_cpp

#include "ContentsDialog.h"
#include <QtDebug>

#define INTRODUCTION    "<H3>INTRODUCTION</H3> \
                         <P> Pic2Lcd"
#define HOWTO           "How to..."

ContentsDialog::ContentsDialog(QWidget *parent): QDialog(parent) {
	setupUi(this);
#if (0)
	QString version = VERSION;
	QString revision = REVISION;
	QString currentNumber = "", lastNumber = "";
	for (int i = 0; i < revision.length(); ++i) {
		if (!revision[i].isDigit()) {
			if (currentNumber != "") {
				lastNumber = currentNumber;
				currentNumber = "";
			}
		} else {
			currentNumber += revision[i];
		}
	}
	if (currentNumber != "") {
		lastNumber = currentNumber;
	}
	if (lastNumber != "") {
		revision = lastNumber;
	}
        applicationTitleLabel->setText("Pic2Lcd - " + version);
//	applicationTitleLabel->setText("Pic2Lcd - " + version + " (revision " + revision + ")");
#endif
}

#endif

void ContentsDialog::on_ContentsTree_activated(QModelIndex index)
{

    int row = index.row();
    int col = index.column();
    qDebug()<< row << col;


#if (0)
    //QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
#endif

    QString Introduction = INTRODUCTION;
    QString Howto = HOWTO;

    // TODO: cannot get correct data
    QString str = index.data(index.row()).toString();
    if (str == "Introduction")
    {
        ContentsBro->setText(Introduction);
    }
    else if(str == "How to...")
    {
        ContentsBro->setText(Howto);
    }
}
